package touro.mancala.client;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Random;

public class Store {
	private ArrayList<Stone> stones;
	private Player player;

	public Store (Player p) {
		stones = new ArrayList<Stone>();
		player = p;
	}

	public Store (int numStones, Player p, Color color) {
		this(p);
		Random random = new Random();
		for (int i = 0; i<numStones; i++) {
			this.addStone(new Stone());
			
		}
	}

	//setters

	public void setStones (Collection<Stone> stones) {
		stones.clear();
		stones.addAll(stones);
	}
	public void clearStones(){
		stones.clear();
	}

	public void addStone (Stone s) {
		stones.add(s);
	}
	public void addStone (Collection<? extends Stone> s) {
		stones.addAll(s);
	}

	public void setPlayer (Player p) {
		player = p;
	}
	
	//getters
	//used for test classes
	public ArrayList<Stone> getStones () {
		return stones;
	}

	public Player getPlayer() {
		return player;
	}

	public int getSize() {
		return stones.size();
	}

	public boolean isEmpty () {
		return stones.isEmpty();
	}

	private Color createColor (Color c, Random random) {
		float[] hsbvals = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
		hsbvals[1] = random.nextFloat();
		if (hsbvals[1] < 0.7f) {
			if (hsbvals[1] < 0.3f) {
				hsbvals[1] = 1.0f - hsbvals[1];
			} else if (hsbvals[1] > 0.4f){
				hsbvals[1]+=0.3f;
			} else {
				hsbvals[1]+=0.4f;
			}
		}
		hsbvals[2] = random.nextFloat();
		if (hsbvals[2] < 0.7f) {
			if (hsbvals[2] < 0.3f) {
				hsbvals[2] = 1.0f - hsbvals[2];
			} else if (hsbvals[2] > 0.4f){
				hsbvals[2]+=0.3f;
			} else {
				hsbvals[2]+=0.4f;
			}
		}
		return Color.getHSBColor(hsbvals[0], hsbvals[1], hsbvals[2]);
	}
}
